<?php
namespace app\user\controller;

use app\common\controller\Front;

class Index extends Front
{
    protected function initialize()
    {
        $this->auth['check'] = true;
        
        $this->auth['cancel_limit'] = '*';
        
        parent::initialize(); 
    }
    
    public function index()
    {
        $this->assign($this->site);

        return $this->fetch(); 
    }

    public function log()
    {
        $args = [
            'limit' => 100,
            'where' => [
                ['log_user_id','eq',$this->user['user_id'],]
            ],
            'order' => [
                'log_id' => 'desc'
            ],
        ];
        if(in_array($this->query['type'],['inc','dec'])){
           array_push($args['where'],['log_type','eq',$this->query['type']]);
        };
        $list = model('common/Log','loglic')->select($args);
        //
        $this->assign('list',$list);
        $this->assign($this->query);
        $this->assign($this->site);
        return $this->fetch(); 
    }
}